<template>
  <div class="color">
    <span>{{ color.identity }}</span>
    <el-color-picker
      class="picker"
      :size="color.size"
      v-model="color.defaultColor"
      @change="change"
    ></el-color-picker>
  </div>
</template>

<script lang="ts">
import { Component, Vue, Prop } from "vue-property-decorator";
import Icolor from "@/interface/Icolor";
import bus from "@/utils/eventBus";
import bgColorModule from "@/store/modules/backgroundColor";

@Component({
  components: {},
})
export default class ColorPicker extends Vue {
  @Prop(Object) color!: Icolor;

  change(color: string): void {
    bgColorModule.changeBgcolor(color);
    bus.$emit("changeColor", color);
  }
}
</script>

<style lang="scss" scoped>
.color {
  width: 100%;
  background-color: green;
  height: 6vh;
  line-height: 6vh;
  position: relative;

  span {
    padding-left: 10px;
  }

  .picker {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
  }
}
</style>
